﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActionWithHugoFailing.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the ActionWithHugoFailing type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Tests.Support.Actions
{
    using System;
    using System.Collections.Generic;

    using Engine;

    using Entities;

    public class ActionWithHugoFailing : ActionBase<Person>
    {
        public ActionWithHugoFailing() { }

        SafContext safContext;

        protected override ProcessStatus  DoAction(SafContext context, Person person)
        {
            if (person.Forename == "Hugo")
                throw new Exception("Hugo - the 2nd Entity has been forced to fail");

            this.safContext = context;
            string x = person.Forename;
            List<Person> peopleList = new List<Person>();
            peopleList.Add(person);

            this.safContext.ActionProperties.Add("People", peopleList, true);

            return ProcessStatus.Success;
        }

        /*
        /// <summary>
        /// Return the name of this Action
        /// </summary>
        /// <returns></returns>
        public override string Name
        {
            get
            {
                return "Collaboris.SharePoint.Libary.Tests.Support.Actions.SimpleActionNoException";
            }
        }
        */

        protected override ProcessStatus UndoAction(SafContext context, Person person)
        {
            this.safContext = context;
            string x = person.Forename;

            List<Person> peopleList = new List<Person>();
            peopleList.Add(person);

            this.safContext.ActionProperties.Add("People", peopleList, true);

            return ProcessStatus.Success;
        }
    }
}